package xsql

import (
	"github.com/Masterminds/squirrel"
	"maintenance/pkg/types"
)

func GenSQLByAreaLevel(areaCode types.AreaCode, rowBuilder squirrel.SelectBuilder) squirrel.SelectBuilder {
	if areaCode.Province != "" {
		rowBuilder = rowBuilder.Where(squirrel.Eq{
			"province ": areaCode.Province,
		})
	}
	if areaCode.City != "" {
		rowBuilder = rowBuilder.Where(squirrel.Eq{
			"city ": areaCode.City,
		})
	}
	if areaCode.Area != "" {
		rowBuilder = rowBuilder.Where(squirrel.Eq{
			"area ": areaCode.Area,
		})
	}

	if areaCode.Street != "" {
		rowBuilder = rowBuilder.Where(squirrel.Eq{
			"street ": areaCode.Street,
		})
	}

	return rowBuilder
}
